import tkinter
from plotmaze import plotSparse, plotMaze
from sparseObstacle import *
from sparseAstar import *
from tkinter import messagebox

startPoint = (0, 0)
endPoint = (99, 99)  # 人为划定起始点与终点
length = 100
width = 100  # 地图大小
obstacleNum = 35  # 障碍物数量
mostR = 10  # 障碍物最大半径
minR = 3
mostAngle = 45  # 最大转角
maxL = 5  # 最大步长
minL = 1  # 最小步长

obstacle = sparseObstacle(obstacleNum, length, width, startPoint, endPoint, mostR, minR)
aStar = Astar(obstacle, Node(point(startPoint[0], startPoint[1])), Node(point(endPoint[0], endPoint[1])), length, width,
              maxL, minL, mostAngle)
path = aStar.run()
pathList = []

if not path:
    tkinter.messagebox.showinfo("该地图未找到路径", "起始点或终止点与障碍物重合，或者实际上并没有通路")
    plotMaze(obstacle, startPoint, endPoint, length, width)
else:
    for i in path:
        pathList.append((i.point.x, i.point.y))
    plotSparse(obstacle, pathList, startPoint, endPoint, length, width)
